<div class="alert alert-info">
    Properly sized logos for {{page.title}} are not ready yet.
</div>
<h2>Search results from <a href="https://logosear.ch/search.html?q={{page.title | url_encode}}">LogoSear.ch</a></h2>
<div class="searchresults logo-container">
    <img src="/images/spinner.svg" style="height:64px;" class="align-content-center" />
</div>
<script>
$(document).ready(function() {
    $.ajax({
        data: {"q": "{{page.title | cgi_escape}}"},
        dataType: "jsonp",
        error: function (xhr, status, err) {
            var content = $(".searchresults").empty();
            content.append($("<div>").addClass("alert").addClass("alert-danger").text(err));
            console.error("ERROR: " + status, err);
        },
        method: "POST",
        success: function (data, status, xhr) {
            //console.log("data=" + JSON.stringify(data));
            var content = $(".searchresults").empty();
            if (!data.success) {
                content.append($("<div>").addClass("alert").addClass("alert-warning").text(data.message));
            }
            else {
                for (var loop in data.results) {
                    //console.log(data.results[loop]);
                    var result = data.results[loop];
                    content.append($("<a>").attr("href", result.source).attr("title", result.description).append($("<img>").attr("src", result.url).css("max-width", "128px").css("max-height", "64px")));
                }
            }
        },
        timeout: 15000,
        url: "https://logosear.ch/api/search.json"
    });
});
</script>
